<template>
  <div class="payment-result">
    <!-- 添加头部 -->
    <header>
      <i class="fa fa-arrow-left" @click="goBack"></i>
      <div class="title">支付结果</div>
      <div class="placeholder"></div>
    </header>

    <div class="content">
      <div class="result-icon success">
        <i class="fa fa-check-circle"></i>
      </div>
      <div class="result-title">支付成功</div>
      <div class="order-info">
        <p>订单编号: {{ orderId }}</p>
        <p>感谢您的购买!</p>
      </div>
      <div class="action-buttons">
        <div class="btn view-order" @click="viewOrder">查看订单</div>
        <div class="btn back-home" @click="goBack">返回商家</div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';

const route = useRoute();
const router = useRouter();

const orderId = ref(route.query.orderId || '');
const businessId = ref(route.query.businessId || '');

const viewOrder = () => {
  router.push({
    path: '/order-detail',
    query: { 
      orderId: orderId.value,
      businessId: businessId.value,
      from: 'payment_result'
    }
  });
};

const goBack = () => {
  if (businessId.value) {
    router.push({
      path: '/businessInfo',
      query: { 
        businessId: businessId.value,
        foodTypeId: 1,
        from: 'index'
      }
    });
  } else {
    router.push('/');
  }
};
</script>

<style scoped>
.payment-result {
  min-height: 100vh;
  background-color: #f7f7f7;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  background-color: #ff6b01;
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

header .fa-arrow-left {
  font-size: 18px;
  cursor: pointer;
  width: 24px;
}

header .title {
  font-size: 18px;
  font-weight: bold;
}

header .placeholder {
  width: 24px;
}

.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  text-align: center;
}

.result-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.result-icon.success {
  color: #67C23A;
}

.result-title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 20px;
}

.order-info {
  margin-bottom: 30px;
}

.order-info p {
  margin: 8px 0;
  color: #666;
}

.action-buttons {
  display: flex;
  gap: 20px;
}

.btn {
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
  min-width: 120px;
  transition: all 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.view-order {
  background-color: #fff;
  border: 1px solid #ff6b01;
  color: #ff6b01;
}

.back-home {
  background-color: #ff6b01;
  color: white;
  box-shadow: 0 2px 6px rgba(255, 107, 1, 0.2);
}
</style> 